import http from '@/utils/http'

const BASE_URL = '/testing/uiCase'

export interface UiCaseResp {
  id: string
  projectId: string
  moduleId: string
  browser: string
  name: string
  description: string
  level: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseDetailResp {
  id: string
  projectId: string
  moduleId: string
  browser: string
  name: string
  description: string
  level: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface UiCasePageQuery extends UiCaseQuery, PageQuery {}

/** @desc 查询UI用例列表 */
export function listUiCase(query: UiCasePageQuery) {
  return http.get<PageRes<UiCaseResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询UI用例详情 */
export function getUiCase(id: string) {
  return http.get<UiCaseDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增UI用例 */
export function addUiCase(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改UI用例 */
export function updateUiCase(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除UI用例 */
export function deleteUiCase(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出UI用例 */
export function exportUiCase(query: UiCaseQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
